// 封装请求：get post
// 面向对象es6 promise

// 引进提示
import {errdata} from './errdata.js'

// GET
let listing = (urling) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: urling,
			method: 'GET'
		}).then((res) => {
			resolve(res[1])
		}).catch((err) => {
			let errs='服务器错误请稍后再试'
			errdata.errlist(errs)
			reject(err)
		})
	})
}

// POST
let publicing = (urling,shopdata) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: urling,
			method: 'POST',
			data:shopdata
		}).then((res) => {
			resolve(res[1])
		}).catch((err) => {
			let errs='服务器错误请稍后再试'
			errdata.errlist(errs)
			reject(err)
		})
	})
}

export {
	listing,publicing
}
